<?php
/**
 * Created by PhpStorm.
 * User: mac
 * Date: 2021/6/11
 * Time: 10:45 PM
 */

namespace Modules\Auth\Services;
use Modules\Common\Services\BaseService;
use Modules\Common\Services\CommonService;
use Modules\Auth\Entities\User;

use Illuminate\Support\Facades\Hash;
class UserService extends BaseService
{
    private $service;
   
    public function __construct(CommonService $service)
    {
        $this->service = $service;
       
    }
    public function store( $request){
        if ($request->filled('password')) {
            $password= $request->password;
            $request->offsetSet('password', Hash::make($request->password));
        }
        $this->service->set(new User(),$request->all());
        $result = $this->service->store();
        if(!$result){
            return false;
        }
        $this->service->setGuzzleHttp('user');
        $this->service->set(new User(),['password'=>$password,'name'=>$request->name]);
        $result = $this->service->userLogin();
        return $result;
    }
}